package com.luban.springcloud.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.luban.springcloud.pojo.User;
import com.luban.springcloud.service.UserFeignClientService;

@RestController
@RequestMapping("/user")
public class UserConsumerController {
	
	@Autowired
	private	UserFeignClientService userFeignClientService;
	
	@GetMapping(value="/get/{id}")
	public User get(@PathVariable("id")Integer id) {
		return userFeignClientService.get(id);
	}
	
	@GetMapping("/list")
	public List<User> list() {
		return userFeignClientService.list();
	}

	@PostMapping(value="/adOrUp")
	public String addOrUpdateUser(User user) {
		return	userFeignClientService.addOrUpdateUser(user);
	}
	
	@GetMapping(value="/delete/{id}")
	public boolean delete(@PathVariable("id")Integer id) {
		return	userFeignClientService.delete(id);
	}
	
	@GetMapping(value="/getServiceInfo")
	public Map<String, Object> getServiceInfo(){
		return userFeignClientService.getServiceInfo();
	}
}
